﻿#region Copyright(C) 2018 FI Ltd. All rights reserved.

// ==================================================================================================
// Copyright(C) 2018 FI Ltd. All rights reserved.
//
// SYSTEM NAME	:   FI.Net Application Framework 
// COMPONENT ID :   FI.EntityFramework
// COMPONENT DESC:  
//
// CREATED DATE/BY: 18 Aug 2018 / Tian Mi
//
// REVISION HISTORY:	DATE/BY			SR#/CS/PM#/OTHERS		DESCRIPTION OF CHANGE
// ==================================================================================================

#endregion

 
using FI.Core.Utilities;
using FI.EntityFramework.Interception;
using MySql.Data.MySqlClient;
using System.Data.Common;
using System.Data.SqlClient;

namespace FI.EntityFramework.Interception
{
    /// <summary>
    /// Represents a set of methods for creating instances of a command helper.
    /// </summary>
    internal static class DbCommandHelperFactory
    {
        /// <summary>
        /// Creates a helper for the specified command.
        /// </summary>
        /// <param name="command">The command being executed.</param>
        /// <returns>The helper for the specified command.</returns>
        public static IDbCommandHelper Create(DbCommand command)
        {
            Guard.ArgumentNotNull(command, "command");

            if (command is SqlCommand)
            {
                return new SqlCommandHelper(command);
            }
            if (command is MySqlCommand)
            {
                return new SqlCommandHelper(command);
            }

            return new UnknownCommandHelper(command);
        }
    }
}